import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as actions from "../store/action"
import { bindActionCreators } from 'redux'
export class TabTitle extends Component {
  render() {
      console.log(this.props,"tab退")
      const {list,activeIndex,setActiveAction}=this.props
    return (
      <div>
          {
              list.length  ? list.map((item,index)=>{
                  return <button 
                  className={index===activeIndex ?'on' :''}
                  key={item.id}
                  onClick={()=>[
                      setActiveAction(index)
                  ]}>{item.title}</button>
              }):'暂无数据'
          }


      </div>
    )
  }
}

const mapStateToProps = (state) => ({
        ...state.reducer
})

const mapDispatchToProps =(dispatch)=>{
     return bindActionCreators(actions,dispatch)
}
   


export default connect(mapStateToProps, mapDispatchToProps)(TabTitle)